package com.shengyuan.manage_os.old.ying.erpm;

import org.json.JSONException;

import com.shengyuan.manage_os.R;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class Actual_JX_RuKuDan_HuangQuan extends Actual_JX_RuKuDan {

	protected EditText editText_rukushuliang_1,editText_rukushuliang_2,editText_rukushuliang_3,editText_rukushuliang_4;
	@Override
	public String MyID() {
		return getClass().getName();
	}
	@Override
	public void onClick(View view) {
		super.onClick(view);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate_copy(savedInstanceState);
		setContentView(R.layout.actual_form_jx_rukudan_huangquan);
		InitControls();
	}
	@Override
	protected void SaveJsonData() {
		try {
			//super.SaveJsonData();
			IsJson1 = true; mFinished = 1; mPrintenabled = 0;
			JsonMyID();
			getTask();
			getCaiLiao();
			getDataExt();
			
			getGPS();
			getCurrentUser();		
			getMemo();
			if (editText_memo!=null) {
				String s = "出库磅单:" + editText_rukushuliang_1.getText().toString() +"吨=" 
									   + editText_rukushuliang_2.getText().toString() +"升\r\n" ; 
				s += "入库磅单:" + editText_rukushuliang_3.getText().toString() +"吨=" 
						   + editText_rukushuliang.getText().toString() +"升\r\n" ; 				
				s += editText_memo.getText().toString();
				mJson.put( getString(R.string.title_actual_form_editText_memo), s);
			}
			save_pic();
		}catch (Exception e) {
		}
	}
	
	@Override
	protected void getDataExt() throws JSONException {
		super.getDataExt();
		
		if (editText_rukushuliang!=null) {
			mJson.put( getString(R.string.title_actual_form_editText_rukushuliang), editText_rukushuliang.getText().toString());
		}
	}
	@Override
	public void Back() {
		this.finish();
	}

	@Override
	public void InitControls() {
		super.InitControls();
		editText_rukushuliang_1= (EditText) findViewById(R.id.editText_rukushuliang_1);
		editText_rukushuliang_2= (EditText) findViewById(R.id.editText_rukushuliang_2);
		editText_rukushuliang_3= (EditText) findViewById(R.id.editText_rukushuliang_3);
		editText_rukushuliang_3.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			
			@Override
			public void onFocusChange(View arg0, boolean arg1) {
				try {
					double d1 = Double.parseDouble(editText_rukushuliang_1.getText().toString());
					double d2 = Double.parseDouble(editText_rukushuliang_2.getText().toString());
					double d3 = Double.parseDouble(editText_rukushuliang_3.getText().toString());
					double d4 =Math.round( d2 / d1 * d3 * 100.00) / 100.00;
					editText_rukushuliang.setText( d4 + "");
				} catch (Exception e) {
				}

			}
		});
	}
	
	@Override
	public Boolean IsPassed() {
		if (super.IsPassed()) {
			if (!CheckEditEmpty(editText_rukushuliang_1)) {
				return false;
			}
			if (!CheckEditEmpty(editText_rukushuliang_2)) {
				return false;
			}
			if (!CheckEditEmpty(editText_rukushuliang_3)) {
				return false;
			}
			if (!CheckEditEmpty(editText_rukushuliang_4)) {
				return false;
			}
			return true;
		}
		return false;
	}
	
}
